<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>仓库管理系统</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta http-equiv="Access-Control-Allow-Origin" content="*">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" href="../../../../resources/lib/layui-v2.5.5/css/layui.css" media="all" />
		<link rel="stylesheet" href="../../../../resources/css/layuicmspublic.css" media="all" />
	</head>
<body>
	<div class="layuimini-container" style="padding-top: 20px;">
		<form class="layui-form layui-row" method="post" id="dataFrm" lay-filter="dataFrm">
		    	<div class="layui-col-md3 layui-col-xs12 user_right">
		    		<div class="layui-upload-list">
		    			<img class="layui-upload-img layui-circle userFaceBtn userAvatar" id="userFace">
						<p id="demoText"></p>
		    		</div>
		    		<button type="button" class="layui-btn layui-btn-primary userFaceBtn"><i class="layui-icon">&#xe67c;</i> 掐指一算，我要换一个头像了</button>
		    		
		    	</div>
		    	<div class="layui-col-md6 layui-col-xs12">
		    		<div class="layui-form-item">
		    			<label class="layui-form-label">登陆名</label>
		    			<div class="layui-input-block">
							<input type="hidden" name="id" />
		    				<input type="text" value="" name="loginname" disabled class="layui-input layui-disabled">
		    			</div>
		    		</div>
		    		<div class="layui-form-item">
		    			<label class="layui-form-label">用户姓名</label>
		    			<div class="layui-input-block">
		    				<input type="text" value="" name="name"   class="layui-input">
		    			</div>
		    		</div>
					<div class="layui-form-item">
						<label class="layui-form-label">用户地址</label>
						<div class="layui-input-block">
							<input type="text" value="" name="address" placeholder="请输入用户地址"  class="layui-input">
						</div>
					</div>
		    		<div class="layui-form-item">
		    			<label class="layui-form-label">个人备注</label>
		    			<div class="layui-input-block">
		    				<textarea placeholder="请输入个人备注" name="remark" class="layui-textarea myself"></textarea>
		    			</div>
		    		</div>
					<div class="layui-form-item" pane="">
						<label class="layui-form-label">性别</label>
						<div class="layui-input-block userSex">
							<input type="radio" name="sex" value="1" title="男" checked="">
							<input type="radio" name="sex" value="0" title="女">
						</div>
					</div>
		    		<div class="layui-form-item">
		    			<div class="layui-input-block">
		    				<button type="button" class="layui-btn" lay-submit="" id="changeUser" lay-filter="changeUser">立即提交</button>
		    				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		    			</div>
		    		</div>
		    	</div>
		    </form>
	</div>
	
	
	<script src="../../../../resources/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
	<script src="../../../../resources/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
	<script src="../../../../resources/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
	<script src="../../../../resources/lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
	<script src="../../../../resources/common/jquery.cookie.min.js" charset="utf-8"></script>
	<script src="../../../../resources/common/common.js" charset="utf-8"></script>
	
	<script>
	    layui.use(['form', 'table','laydate','layer','upload'], function () {
	        var form = layui.form;
	        var table = layui.table;
			var laydate=layui.laydate;
			var layer=layui.layer;
			var upload=layui.upload;
			
			//查询当前用户
			$.get(api+"user/getCurrentUser",function(res){
				$("#userFace").attr("src",baseUrl + res.data.imgpath);
				form.val("dataFrm",res.data);
			});
			form.on("submit(changeUser)",function(data){
				//loading层
				var index = layer.load(2, {
				  shade: [0.5,'#fff'] //0.1透明度的白色背景     RGB  red  green blue
				});
				var params= $("#dataFrm").serialize();
				$.post(api+"user/updateUser",params, function(res){
					layer.msg(res.msg);
					//关闭loading层
					layer.close(index);
				})
				return false;
			})
			
			//绑定文件上传的控件
			//普通图片上传
			upload.render({
			    elem: '.userFaceBtn'
			    ,url: api+'file/uploadUserImage' //改成您自己的上传接口
				,field: "mf" //设定文件域的字段名	
				,acceptMime: 'image/*'
				,size:2000
			    ,before: function(obj){
			      //预读本地文件示例，不支持ie8
			      obj.preview(function(index, file, result){
			        $('#userFace').attr('src', result); //图片链接（base64）
			      });
			    }
			    ,done: function(res){
			      //如果上传失败
			      if(res.code > 0){
			        return layer.msg('上传失败');
			      }else if(res.code == 0){
					  //上传成功
					  //该接口返回的相应信息（response）必须是一个标准的 JSON 格式 详细参照文档
					 return layer.msg('上传成功');
				  }
			      
			    }
			    ,error: function(){
			      //演示失败状态，并实现重传
			      var demoText = $('#demoText');
			      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
			      demoText.find('.demo-reload').on('click', function(){
			        uploadInst.upload();
			      });
			    }
			  });
			
			
	    });
	</script>

</body>
</html>
